package com.Maykk.Demo01;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

/**
 * @ClassName: Demo01
 * @Description: TODO Set 集合
 * @Author: MaykkStar@163.com
 */
public class Demo01 {
    public static void main(String[] args) {
        // Set 不包含重复的元素，没有顺序，没有索引，所以只能只用迭代器或者增强 for 遍历
        Set<String> set = new HashSet<>();
        set.add("JavaSE");
        set.add("MySQL");
        set.add("HTML");
        set.add("CSS");
        set.add("JavaScript");
        Iterator<String> it = set.iterator();
        while (it.hasNext()) {
            System.out.println(it.next());
        }
        System.out.println("++++++++++++++++++++");
        for (String str : set) {
            System.out.println(str);
        }
    }
}
